
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>table</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<table id="demo" lay-filter="test"></table>
</body>
</html>
<script src="./layui/layui.js"></script>
<script>
    //JS
    layui.use([ 'table'], function () {
        var table = layui.table


        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , url: './test1' //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                , {field: 'userName', title: '用户名', width: 80}
                , {field: 'phone', title: '手机号', width: 80, sort: true}
                , {field: 'email', title: '邮箱', width: 80}
                , {field: 'role', title: '角色', width: 80}
            ]]
        });
    });
</script>